#include "Node.hpp"

void Node::update(float time) {
  m_position += time * m_speed;
  if (m_attachedEntity) m_attachedEntity->update(time);
  for (childNodeList_t::iterator it = m_childNodeList.begin();
                                 it != m_childNodeList.end(); it++)
      (*it).second->update(time);
}

void Node::render() {
  glTranslatef(m_position.x,m_position.y,m_position.z);
  glRotatef(m_angle,0.f,0.f,1.f);
  for (childNodeList_t::iterator it = m_childNodeList.begin();
                                 it != m_childNodeList.end(); it++) {
      glPushMatrix();
      glm::vec3 dec = (*it).first;
      glTranslatef(dec.x,dec.y,dec.z);
      (*it).second->render();
      glPopMatrix();
  };
  if (m_attachedEntity) m_attachedEntity->render();
}
